package com.project.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ClassesBean;
import com.project.mapper.IClassesMapper;
import com.project.service.IClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author liuyulai
 * Created with IntelliJ IDEA.
 * Date: 21.7.11
 * Time: 16:08
 * Description: 班级业务层实现类
 */
@Service
@Transactional
public class ClassesServiceImpl implements IClassesService {
    @Autowired
    private IClassesMapper iClassesMapper;

    @Override
    public PageInfo<ClassesBean> showClassByItem(int pageNo, int schoolId) {
        PageHelper.startPage(pageNo, 3);
        PageInfo<ClassesBean> info = PageInfo.of(iClassesMapper.showClassByItem(schoolId));
        return info;
    }

    @Override
    public void addNewClass(ClassesBean classesBean) {
        iClassesMapper.addNewClass(classesBean);
    }

    @Override
    public ClassesBean showClassById(int classesId) {
        return iClassesMapper.showClassById(classesId);
    }

    @Override
    public void updateClassInfo(int classesId, String teacherName) {
        iClassesMapper.updateClassInfo(classesId, teacherName);
    }

    @Override
    public List<ClassesBean> findClassBySchoolId(int schoolId) {
        return iClassesMapper.findClassBySchoolId(schoolId);
    }
}
